using System;
using System.Collections;
using SMS.SMPPClient;

namespace SMS.SMPPClient.PDU.Incoming
{
    /// <summary>
    /// Class to define an SMSC bind response.
    /// </summary>
    public class SMPPBindResponse : SMPPResponse
    {
        private string _SystemID;

        /// <summary>
        /// The ID of the SMSC.
        /// </summary>
        public string SystemID
        {
            get
            {
                return _SystemID;
            }
        }

        /// <summary>
        /// The SMPP version supported by SMSC.
        /// </summary>
        public string SCInterfaceVersion
        {
            get
            {
                return tlvTable.GetOptionalParamString((ushort)
                    PDU.OptionalParamCodes.SC_interface_version);
            }
        }

        /// <summary>
        /// Creates a bind response PDU.
        /// </summary>
        /// <param name="response">The byte response from the
        /// SMSC.</param>
        public SMPPBindResponse(byte[] response)
            : base(response)
        {
            DecodeSMSCResponse();
        }

        /// <summary>
        /// Decodes the bind response from the SMSC.
        /// </summary>
        protected override void DecodeSMSCResponse()
        {
            byte[] remainder = ResponseAfterHeader;
            _SystemID = GetStringFromBody(ref remainder);
            //fill the TLV table if applicable
            tlvTable.TranslateTLVDataIntoTable(remainder);
        }
    }
}
